﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="HtmlHelpersExtensions.cs" company="ecblog.codeplex.com">
//   emrecoskun.net -  
// </copyright>
// <summary>
//   Defines the HtmlHelpersExtensions type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace EC.Extensions
{
    using System.Web;
    using System.Web.Mvc;

    /// <summary>
    /// The html extensions
    /// </summary>
    public static class HtmlHelpersExtensions
    {
        /// <summary>
        /// Gets the current theme.
        /// </summary>
        /// <param name="html">The HTML.</param>
        /// <returns>The name of  current theme</returns>
        public static string GetCurrentTheme(this HtmlHelper html)
        {
            if (html.ViewContext.HttpContext.Session != null)
            {
                if (html.ViewContext.HttpContext.Session["Theme"] == null)
                {
                    html.ViewContext.HttpContext.Session["Theme"] = "Vista";
                }

                return html.ViewContext.HttpContext.Session["Theme"].ToString();
            }

            return "Vista";
        }

        /// <summary>
        /// Decodes the specified HTML.
        /// </summary>
        /// <param name="html">The HTML.</param>
        /// <param name="htmlEncodedString">The HTML encoded string.</param>
        /// <returns>The decoded html code</returns>
        public static string Decode(this HtmlHelper html, string htmlEncodedString)
        {
            return HttpUtility.HtmlDecode(htmlEncodedString);
        }
    }
}